﻿namespace UnityEditor.Graphs.AnimationBlendTree
{
    using System;
    using System.Collections.Generic;
    using UnityEditor.Graphs;
    using UnityEngine;

    public class Node : UnityEditor.Graphs.Node
    {
        public List<UnityEditor.Graphs.AnimationBlendTree.Node> children = new List<UnityEditor.Graphs.AnimationBlendTree.Node>();
        private UnityEditor.Graphs.AnimationBlendTree.Node m_Parent;
        public Motion motion;
        public float weight = 1f;

        public int childIndex
        {
            get
            {
                if (this.m_Parent == null)
                {
                    return -1;
                }
                return this.m_Parent.children.IndexOf(this);
            }
        }

        public bool isLeaf
        {
            get
            {
                return (this.children.Count == 0);
            }
        }

        public UnityEditor.Graphs.AnimationBlendTree.Node parent
        {
            get
            {
                return this.m_Parent;
            }
            set
            {
                if (this.m_Parent != null)
                {
                    this.m_Parent.children.Remove(this);
                }
                this.m_Parent = value;
                this.m_Parent.children.Add(this);
            }
        }

        public UnityEngine.Color weightColor
        {
            get
            {
                return UnityEngine.Color.Lerp(new UnityEngine.Color(0.8f, 0.8f, 0.8f, 1f), UnityEngine.Color.white, Mathf.Pow(this.weight, 0.5f));
            }
        }

        public UnityEngine.Color weightEdgeColor
        {
            get
            {
                return UnityEngine.Color.Lerp(UnityEngine.Color.white, new UnityEngine.Color(0.42f, 0.7f, 1f, 1f), Mathf.Pow(this.weight, 0.5f));
            }
        }
    }
}

